package Dao;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import Entity.Student;
import junit.framework.Assert;

public class StudentsInformationDaoTest {
	Student student=null;
	StudentsInformationDao studao=new StudentsInformationDao();
	List<Student> slist=new ArrayList<Student>();

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testAddStudent() {
		String studentNo="20161981",studentName="王五",sex="男",dept="计算机科学与技术学院",major="网络工程",studentClass="2016321",studentId="320922199805138447",
		pwd="20161946",tel="18522599037";
		assertEquals(1,studao.addStudent(studentNo, studentName, sex, dept, major, studentClass, studentId, pwd, tel));
	}

	@Test
	public void testDeleteStudentByNo() {
		assertEquals(1,studao.deleteStudentByNo("20161980"));
	}

	@Test
	public void testAlterPassword() {
		assertEquals(1,studao.alterPassword("20161946", "20161946"));
	}

	@Test
	public void testAlterStudentInformation() {
		student=new Student("20161974","学生27","女","计算机科学与技术学院","网络工程","2016321","320922199805138447","20161946","18522599037");
		assertEquals(1,studao.alterStudentInformation(student));
	}

	@Test
	public void testQueryRecordCount() {
		assertEquals(33,studao.queryRecordCount());
	}

	@Test
	public void testQueryStudentByNo() {
		assertEquals("20161946",studao.queryStudentByNo("20161946").studentNo);
	}

	@Test
	public void testShowAllStudents() {
		slist=studao.showAllStudents();
		Assert.assertNotNull(slist);
	}

	@Test
	public void testShowAllStudentsByPage() {
		slist=studao.showAllStudentsByPage(1);
		Assert.assertNotNull(slist);
	}

}
